package com.itheima.reggie.controller;

import com.itheima.reggie.common.R;
import com.itheima.reggie.service.ReportService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;
import java.util.List;
import java.util.Map;

@Slf4j
@RestController
@RequestMapping("/report")
public class ReportController {
    @Autowired
    private ReportService reportService;

    //菜品统计
    @GetMapping("/dish")
    public R<List> dish(@DateTimeFormat(pattern = "yyyy-MM-dd") Date beginTime,
                        @DateTimeFormat(pattern = "yyyy-MM-dd") Date endTime){
        List<Map<String,Integer>> maps = reportService.dish(beginTime,endTime);
        System.out.println(maps);
        return R.success(maps);
    }

    //套餐统计
    @GetMapping("/setmeal")
    public R<List> setmeal(@DateTimeFormat(pattern = "yyyy-MM-dd") Date beginTime,
                        @DateTimeFormat(pattern = "yyyy-MM-dd") Date endTime){
        List<Map<String,Integer>> maps = reportService.setmeal(beginTime,endTime);
        System.out.println(maps);
        return R.success(maps);
    }
}
